package com.ruoyi.web.controller.market.source;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.SourceMemberDataInfo;
import com.ruoyi.source.service.ISourceMemberDataInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.SourceMemberDataInfoWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线索用户资质信息Controller
 * 
 * @author ruoyi
 * @date 2024-08-22
 */
@Controller
@RequestMapping("/source/dataInfo")
public class SourceMemberDataInfoController extends BaseController
{
    private String prefix = "source/dataInfo";

    @Autowired
    private ISourceMemberDataInfoService sourceMemberDataInfoService;

    @RequiresPermissions("source:dataInfo:list")
    @GetMapping()
    public String dataInfo()
    {
        return prefix + "/dataInfo";
    }

    /**
     * 查询线索用户资质信息列表
     */
    @RequiresPermissions("source:dataInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SourceMemberDataInfo sourceMemberDataInfo)
    {
        startPage();
        List<Map<String, Object>> mapList = sourceMemberDataInfoService.selectSourceMemberDataInfoListMap(sourceMemberDataInfo);
        mapList = new SourceMemberDataInfoWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出线索用户资质信息列表
     */
    @RequiresPermissions("source:dataInfo:export")
    @Log(title = "线索用户资质信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SourceMemberDataInfo sourceMemberDataInfo)
    {
        List<SourceMemberDataInfo> list = sourceMemberDataInfoService.selectSourceMemberDataInfoList(sourceMemberDataInfo);
        ExcelUtil<SourceMemberDataInfo> util = new ExcelUtil<SourceMemberDataInfo>(SourceMemberDataInfo.class);
        return util.exportExcel(list, "线索用户资质信息数据");
    }

    /**
     * 新增线索用户资质信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存线索用户资质信息
     */
    @RequiresPermissions("source:dataInfo:add")
    @Log(title = "线索用户资质信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SourceMemberDataInfo sourceMemberDataInfo)
    {
        return toAjax(sourceMemberDataInfoService.insertSourceMemberDataInfo(sourceMemberDataInfo));
    }

    /**
     * 修改线索用户资质信息
     */
    @RequiresPermissions("source:dataInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SourceMemberDataInfo sourceMemberDataInfo = sourceMemberDataInfoService.selectSourceMemberDataInfoById(id);
        mmap.put("sourceMemberDataInfo", sourceMemberDataInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存线索用户资质信息
     */
    @RequiresPermissions("source:dataInfo:edit")
    @Log(title = "线索用户资质信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SourceMemberDataInfo sourceMemberDataInfo)
    {
        return toAjax(sourceMemberDataInfoService.updateSourceMemberDataInfo(sourceMemberDataInfo));
    }

    /**
     * 删除线索用户资质信息
     */
    @RequiresPermissions("source:dataInfo:remove")
    @Log(title = "线索用户资质信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sourceMemberDataInfoService.deleteSourceMemberDataInfoByIds(ids));
    }
}
